<!doctype html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<title>Shiseido WechatWork Admin后台管理系统</title>
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
		<link rel="stylesheet" href="./static/css/font.css">
		<link rel="stylesheet" href="./static/css/weadmin.css">
		<script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
		<script src="publicjs/jquery-1.8.0.min.js" charset="utf-8"></script>
		<script src="publicjs/smallkingutil.js" charset="utf-8"></script>
	</head>

	<body>
		<!-- 顶部开始 -->
		<div class="container">
			<div class="logo">
				<a href="./index.html">Shiseido WechatWork Admin</a>
			</div>
			<div class="left_open">
				<i title="展开左侧栏" class="iconfont">&#xe699;</i>
			</div>
			<!-- 以后有用就放开 -->
			<ul class="layui-nav right" lay-filter="">
				<li class="layui-nav-item">
					<a id="a_nickname" href="javascript:;">Admin</a>
					<dl class="layui-nav-child">
						<!-- 二级菜单 -->
						<dd>
							<a class="loginout" onclick="changePassword()">修改密码</a>
						</dd>
						<dd>
							<a class="loginout" onclick="SwitchAccount()">退出登录</a>
						</dd>
					</dl>
				</li>
			</ul>
		</div>
		<!-- 顶部结束 -->
		<!-- 中部开始 -->
		<!-- 左侧菜单开始 -->
		<div class="left-nav">
			<div id="side-nav">
				<ul id="nav">

				</ul>
			</div>
		</div>
		<!-- <div class="x-slide_left"></div> -->
		<!-- 左侧菜单结束 -->
		<!-- 右侧主体开始 -->
		<div class="page-content">
			<div class="layui-tab tab" lay-filter="wenav_tab" id="WeTabTip" lay-allowclose="true">
				<ul class="layui-tab-title" id="tabName">
					<li>首页</li>
				</ul>
				<div class="layui-tab-content">
					<div class="layui-tab-item layui-show">
						<iframe src='./pages/home.html' frameborder="0" scrolling="yes" class="weIframe"></iframe>
					</div>
				</div>
			</div>
		</div>
		<div class="page-content-bg"></div>
		<!-- 右侧主体结束 -->
		<!-- 中部结束 -->
		<!-- 底部开始 -->
		<div class="footer">
			<div class="copyright">Copyright ©2018 WeAdmin v1.0 All Rights Reserved</div>
		</div>
		<!-- 底部结束 -->
		<script type="text/javascript">
			layui.config({
				base: './static/js/',
				version: '101100'
			}).use('admin');
			layui.use(['jquery', 'admin'], function() {
				var $ = layui.jquery;
				window.SwitchAccount = function() {
					// 发送ajax请求到后台 推出当前登录
					var ajaxParam = {
						url: commonUtil.domain() + '/admin/login/out'
					}
					ajaxUtil.post(ajaxParam, function(data) {
						if(data.code == 200) {
							// 将本地存储用户localStorage的数据删除 然后跳转登录页
							localStorage.removeItem("user_info");
							// 然后关闭所有table
							closeAllTab();
							location.href = './login.html';
						}
					});
				}
				window.changePassword = function() {
					// 弹出修改密码界面
					layer.open({
						type: 2,
						area: ['500px', '300px'],
						fix: false, //不固定
						maxmin: true,
						shadeClose: true,
						shade: 0.4,
						title: "重置密码",
						content: './pages/right/password-reset.html'
					});
				}
				$(function() {
					commonUtil.setMaxLength(40);
					// 读取sessionStorage里面的用户信息
					var userInfo = JSON.parse(localStorage.getItem("user_info"));
					if(userInfo) {
						// 界面显示nickname
						$("#a_nickname").html(userInfo.nickname);
						// 如果存在userInfo 查看userInfo的权限信息 隐藏菜单模块
						var menuList = userInfo.menuList;
						window.menuList = menuList;
						console.info(menuList);
						// 根据父级ID 遍历集合 得到子集				
						window.getChildrenList = function(parentId){
							var childList = [];
							for(var i = 0; i < menuList.length; i ++){
								var item = menuList[i];
								if(item.pid == parentId){
									childList.push(item);
								}
							}
							return childList;
						}
						// 拼接第三层菜单
						window.thirdMenu = function(parentHtml, parentId){
							var thirdList = getChildrenList(parentId);
							var htmlStr = '<ul class="sub-menu">';
							for(var i = 0; i < thirdList.length; i ++){
								var thirdItem = thirdList[i];
								var thirdLowList = getChildrenList(thirdItem.id);
								var linkstr = "";
								if(thirdList.length >= 1){
									linkstr = '<a href="javascript:;">';
								}else{
									linkstr = '<a _href="' + thirdItem.link + '">';
								}
								htmlStr += '<li id="' + thirdItem.id + '">'
									+ linkstr
									+ '<i class="layui-icon">&#' + thirdItem.icon + ';</i>'
									+ '<cite>' + thirdItem.name + '</cite>';
								if(thirdLowList.length >= 1){
									htmlStr += '<i class="iconfont nav_right">&#xe697;</i>';
								}
								htmlStr += '</a>';
								htmlStr += '</li>';
							}
							htmlStr += '</ul>';
							alert(htmlStr);
							parentHtml.append(htmlStr);
						}
						// 拼接第二层
						window.secondMenu = function(parentHtml, parentId){
							var lowList = getChildrenList(parentId);
							var htmlStr = '<ul class="sub-menu">';
							for(var i = 0; i < lowList.length; i ++){
								var childItem = lowList[i];
								var sencodlowList = getChildrenList(childItem.id);
								var linkstr = "";
								if(sencodlowList.length >= 1){
									linkstr = '<a href="javascript:;">';
								}else{
									linkstr = '<a _href="' + childItem.link + '">';
								}
								htmlStr += '<li id="' + childItem.id + '">'
									+ linkstr
									+ '<i class="layui-icon">&#' + childItem.icon + ';</i>'
									+ '<cite>' + childItem.name + '</cite>';
								if(sencodlowList.length >= 1){
									htmlStr += '<i class="iconfont nav_right">&#xe697;</i>';
								}
								htmlStr += '</a>';
								htmlStr += '</li>';
							}
							htmlStr += '</ul>';
							parentHtml.append(htmlStr);
							// 拼接第三层菜单
							for(var i = 0; i < lowList.length; i ++){
								if(getChildrenList(lowList[i].id).length >= 1){
									secondMenu($("#" + lowList[i].id), lowList[i].id);
								}
							}
						}
						// 拼接第一层菜单 
						var childrenList = getChildrenList("super_resource");
						for(var i = 0; i < childrenList.length; i ++){
							var item = childrenList[i];
							var htmlStr = '<li id="' + item.id + '">'
								+ '<a href="javascript:;">'
								+ '<i class="layui-icon">&#' + item.icon + ';</i>'
								+ '<cite>' + item.name + '</cite>';
							var secondList = getChildrenList(item.id);
							if(secondList.length >= 1){
								htmlStr += '<i class="iconfont nav_right">&#xe697;</i>';
							}
							htmlStr += '</a>';
							htmlStr += '</li>';
							$('#nav').append(htmlStr);
							var parentHtml = $("#" + item.id);
							secondMenu(parentHtml, item.id);
						}
						
					}
					return false;
				});
			});
		</script>

	</body>
	<!--Tab菜单右键弹出菜单-->
	<ul class="rightMenu" id="rightMenu">
		<li data-type="fresh">刷新</li>
		<li data-type="current">关闭当前</li>
		<li data-type="other">关闭其它</li>
		<li data-type="all" id="closeAllTab">关闭所有</li>
	</ul>

</html>